package bo;
import java.sql.SQLException;
import java.util.*;
import dao.*;
import java.sql.CallableStatement;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
 */
public class StoredProcedure {

    private String procname;
    private Vector<String> types;
    public StoredProcedure(String name) {

        procname = name;
    }
    /**
     * @param tuple 
     * @param database 
     */
    public boolean run(Vector<String> tuples, DbHandler database) {
       String proc = "CALL "+procname+"(";
       if(tuples.size()!=0)
           proc+=tuples.get(0);

       for(int i=1;i<tuples.size();i++)
           proc+=","+tuples.get(i);
       proc+=");";
        try {
            System.out.println("Corriendo procedimiento:"+proc);

            database.runSql(proc);
        } catch (Exception ex) {
            Logger.getLogger(StoredProcedure.class.getName()).log(Level.SEVERE, null, ex);
            return false;
        }
       return true;
    }

    /**
     * @return 
     */
    public Vector<String> getTypes() {
        return types;
    }

    /**
     * @param types 
     */
    public void setTypes(Vector<String> types) {
        this.types=types;
    }

    /**
     * @return 
     */
    public String getProcname() {
        return procname;
    }

    /**
     * @param procname 
     */
    public void setProcname(String procname) {
        this.procname=procname;
    }
}

